package com.example.task1.ui.AllService.Gover;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.bean.GovernmentMyAppealBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class GovernmentMyAppealAdapter extends BaseAdapter<GovernmentMyAppealBean.RowsDTO> {

    private Context context;
    private List<GovernmentMyAppealBean.RowsDTO> mData = new ArrayList<>();
    private ImageView image;
    private TextView tvTitle;
    private TextView tvContent;
    private TextView tvUndertaker;
    private TextView tvDetailResult;
    private TextView tvAppealCategoryName;

    public GovernmentMyAppealAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<GovernmentMyAppealBean.RowsDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.gvoernmentmyappleallist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<GovernmentMyAppealBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, GovernmentMyAppealBean.RowsDTO date) {
        MyApplication.glide(image, date.getImgUrl());
        tvAppealCategoryName.setText("诉求分类：" + date.getAppealCategoryName());
        tvContent.setText("内容：" +date.getContent());
        tvDetailResult.setText("处理结果：" +date.getDetailResult());
        tvTitle.setText(date.getTitle());
        tvUndertaker.setText("承办单位：" +date.getUndertaker());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        image = view.findViewById(R.id.image);
        tvTitle = view.findViewById(R.id.tv_title);
        tvContent = view.findViewById(R.id.tv_content);
        tvUndertaker = view.findViewById(R.id.tv_undertaker);
        tvDetailResult = view.findViewById(R.id.tv_detailResult);
        tvAppealCategoryName = view.findViewById(R.id.tv_appealCategoryName);
    }
}
